package com.chinacoal.microservice.api.model.resource;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class TableCanvasData extends CanvasData {

	protected FormCanvasData head;
	protected Map<String,Map<String,String>> title;
	
	public FormCanvasData getHead() {
		return head;
	}

	public void setHead(FormCanvasData head) {
		this.head = head;
	}

	public Map<String, Map<String, String>> getTitle() {
		return title;
	}

	public void setTitle(Map<String, Map<String, String>> title) {
		this.title = title;
	}

	public TableCanvasData(){
		this.type = "table";
	}
	
	public TableCanvasData addFormCanvasData(FormCanvasData formCanvasData){
		if(head == null){
			this.head = new FormCanvasData();
		}
		this.head = formCanvasData;
		return this;
	}
	
	public TableCanvasData add(RecordData record){
		if(data == null){
			this.data = new ArrayList<Object>();
		}
		if(title == null){
			this.title = new HashMap<String,Map<String,String>>();
		}
		
		title.putAll(record.getTitles());
		this.data.add(record.getData());
		return this;
	}
}
